package com.tanhua.server.service;


import com.alibaba.dubbo.config.annotation.Reference;
import com.tanhua.dubbo.server.api.UserLocationApi;
import com.tanhua.server.pojo.User;
import com.tanhua.server.utils.UserThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BaiduService {


    @Reference(version = "1.0.0")
    private UserLocationApi userLocationApi;

    /**
     * 上报地理信息
     *
     * @param longitude 经度
     * @param latitude  纬度
     * @param address
     * @return
     */
    public Boolean updateLocation(Double longitude, Double latitude, String address) {

        try {
            //获取用户信息
            User user = UserThreadLocal.get();
            userLocationApi.updateUserLocation(user.getId(), longitude, latitude, address);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}
